<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ include file="../../base.jsp" %>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 页面meta /-->
</head>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <!-- 内容头部 -->
    <section class="content-header">
        <h1>
            系统管理
            <small>个人管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="${pageContext.request.contextPath}/home/main.do" target="_parent"><i class="fa fa-dashboard"></i> 首页</a></li>
            <%--<li><a href="/system/user/list.do">用户列表</a></li>--%>
        </ol>
    </section>
    <!-- 内容头部 /-->

    <!-- 正文区域 -->
    <section class="content">

        <!--订单信息-->
        <div class="panel panel-default">
            <div class="panel-heading">用户信息</div>
            <form id="editForm" action="/system/user/edit2.do" method="post" enctype="multipart/form-data">
                <input type="hidden" id="id" name="id" value="${user.id}">
                <input type="hidden" id="deptName" name="deptName" value="${user.deptName}">
                <div class="row data-type" style="margin: 0px">
                    <div class="col-md-2 title">用户名称</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="用户名称" name="userName"
                               value="${user.userName}">
                    </div>

                    <div class="col-md-2 title">邮箱</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="邮箱" name="email" value="${user.email}">
                    </div>

                    <div class="col-md-2 title">密码</div>
                    <div class="col-md-4 data">
                        <input type="password" class="form-control" id="password" placeholder="密码" name="password"
                               value="${user.password}">
                    </div>

                    <%--<div class="col-md-2 title">薪水</div>--%>
                    <%--<div class="col-md-4 data">--%>
                    <%--<input type="text" class="form-control" placeholder="薪水" name="salary" value="${user.salary}">--%>
                    <%--</div>--%>

                    <%--<div class="col-md-2 title">状态</div>--%>
                    <%--<div class="col-md-4 data">--%>
                    <%--<div class="form-group form-inline">--%>
                    <%--<div class="radio"><label><input type="radio" ${user.state==0?'checked':''} name="state" value="0">停用</label></div>--%>
                    <%--<div class="radio"><label><input type="radio" ${user.state==1?'checked':''} name="state" value="1">启用</label></div>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <div class="col-md-2 title">上传头像</div>
                    <div class="col-md-4 data">
                        <input type="file" id="file" name="file" class="form-control">
                    </div>


                    <div class="col-md-2 title">电话</div>
                    <div class="col-md-4 data">
                        <input type="text" class="form-control" placeholder="电话" id="telephone" name="telephone"
                               value="${user.telephone}">
                        <span id="telephoneInfo" style="font-size:10px"></span>
                    </div>


                    <div class="col-md-2 title">性别</div>
                    <div class="col-md-4 data">
                        <div class="form-group form-inline">
                            <div class="radio"><label><input type="radio" ${user.gender==0?'checked':''} name="gender"
                                                             value="0">男</label></div>
                            <div class="radio"><label><input type="radio" ${user.gender==1?'checked':''} name="gender"
                                                             value="1">女</label></div>
                        </div>
                    </div>

                    <%--<div class="col-md-2 title">岗位</div>--%>
                    <%--<div class="col-md-4 data">--%>
                    <%--<input type="text" class="form-control" placeholder="岗位" name="station" value="${user.station}">--%>
                    <%--</div>--%>

                    <div class="col-md-2 title">验证码</div>
                    <div class="col-md-4 data">
                        <input type="text" id="smsCode" name="smsCode" class="check" placeholder="请输入验证码">
                        <a href="javaScript:void(0)" id="sendSmsCode">发送手机验证码</a>
                    </div>

                    <div class="col-md-2 title">出生年月</div>
                    <div class="col-md-4 data">
                        <div class="input-group date">
                            <div class="input-group-addon">
                                <i class="fa fa-calendar"></i>
                            </div>
                            <input type="text" placeholder="出生年月" class="form-control pull-right" name="birthday"
                                   value="${user.birthday}" id="datepicker1">
                        </div>
                        <%--</div>--%>
                        <%--<div class="col-md-2 title">排序号</div>--%>
                        <%--<div class="col-md-4 data">--%>
                        <%--<input type="text" class="form-control" placeholder="排序号" name="orderNo" value="${user.orderNo}">--%>
                        <%--</div>--%>
                        <%--<div class="col-md-2 title">说明</div>--%>
                        <%--<div class="col-md-4 data">--%>
                        <%--<input type="text" class="form-control" placeholder="说明" name="remark" value="${user.remark}">--%>
                        <%--</div>--%>
                    </div>
            </form>
        </div>
        <!--订单信息/-->

        <!--工具栏-->
        <div class="box-tools text-center">
            <button type="button" id="submit" class="btn bg-maroon">保存</button>
            <button type="button" class="btn bg-default" onclick="history.back(-1);">返回</button>
        </div>
        <!--工具栏/-->

    </section>
    <!-- 正文区域 /-->

</div>
<!-- 内容区域 /-->
</body>
<script src="../../plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="../../plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<link rel="stylesheet" href="../../css/style.css">
<script>
    $('#datepicker').datepicker({
        autoclose: true,
        format: 'yyyy-mm-dd'
    });
    $('#datepicker1').datepicker({
        autoclose: true,
        format: 'yyyy-mm-dd'
    });
</script>
<script>
    //<a href="javaScript:void(0)" id="sendSmsCode">发送手机验证码</a>
    //<input type="text" id="telephone" name="telephone" placeholder="请输入您的手机号">
    //  <span id="telephoneInfo" style="font-size:10px"></span>
    //绑定点击事件
    $("#sendSmsCode").click(function () {
        //1.获得手机号
        var phoneVal = $("#telephone").val();
        if (phoneVal == '') {
            alert("手机号不能为空")

            return;
        }
        //2.发送ajax
        var url = "/system/user/loginSendSms.do";
        var data = {'telephone': phoneVal};
        $.post(url, data, function (resultInfo) {
            if (resultInfo.flag) {//true  发送成功
                alert(resultInfo.successMsg);
            } else {//发送失败
                alert(resultInfo.errorMsg);
            }
        }, "json")
    })
</script>
<script>
    //页面加载函数 给id=username 的文本框绑定失去焦点事件 -> 用户名的校验
    $(function () {
        //绑定事件
        $("#submit").click(function () {
            //1.获得用户输入的值
            var smsCodeVal = $("#smsCode").val();
            var passwordVal = $("#password").val();
            if (passwordVal == '' & smsCodeVal == '') {
                href = document.getElementById("editForm").submit();
            }
            if (smsCodeVal == '' & passwordVal != '') {
                alert("修改密码后验证码不能为空");
                return;
            }
            if (smsCodeVal != '' & passwordVal != '') {
                //2.发送ajax请求
                var url = "/system/user/smsCode.do";
               var data = {'smsCode': smsCodeVal};// 'action':'checkName' 执行的方法 我们自己写死的
                $.post(url, data, function (resultInfo) {
                    //alert(resultInfo);
                    //<span id="userInfo" style="font-size:10px"></span> 提示框
                    if (resultInfo.flag) {//true
                        //alert(resultInfo.successMsg)
                        alert(resultInfo.successMsg);
                        href = document.getElementById("editForm").submit();
                    } else {
                        //alert(resultInfo.errorMsg)
                        alert(resultInfo.errorMsg);
                    }
                }, "json");
            }
        })
    })
</script>
</html>